Skip to content

(grid): rename pruneStaleSubagents so sidebar.js stops shadowing it - #137

Merged
devsuitup merged 1 commit into
mainfrom
fix/grid-subagent-pills
Aug 23, 2026
Merged

(grid): rename pruneStaleSubagents so sidebar.js stops shadowing it#137
devsuitup merged 1 commit into
mainfrom
fix/grid-subagent-pills

Conversation

@JeanBaptisteRenard

@JeanBaptisteRenard JeanBaptisteRenard commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Renderer files load as plain non-module scripts sharing one global scope, and index.html loads sidebar.js (:136) after grid-view.js (:132). Both declared a top-level pruneStaleSubagents(), so the later declaration won: grid-view's wrapInGridCard() was pruning the sidebar's activeSubagentsByParent map instead of the grid's own activeSubagents.

A grid subagent pill therefore stayed "running" forever whenever the parent PTY died before the matching subagent-completed event, and every grid card re-wrap fired a spurious prune of the sidebar's map.

Renames the grid-side function only; sidebar.js is untouched.

The listener-arity half of this PR's original scope shipped separately in #142, so this branch was rebuilt on current main and now carries the rename alone.

test/dom-grid-sidebar-prune-collision.test.js pins both the absence of colliding top-level names across the two files and the end-to-end TTL prune through the real wrapInGridCard() call site. Both assertions fail on main without the rename:

✖ grid-view.js and sidebar.js declare no colliding top-level prune name
  actual: [ 'pruneStaleSubagents' ]  expected: []
✖ a stale grid subagent is pruned by TTL when grid-view.js and sidebar.js load in index.html order
  stale subagent must be pruned from the grid's own map — 1 !== 0

JeanBaptisteRenard added a commit that referenced this pull request Aug 21, 2026
…debar.js

grid-view.js and sidebar.js both declared a top-level function
pruneStaleSubagents() as classic <script> tags sharing one global
scope; sidebar.js loads after grid-view.js (index.html:129 vs :133),
so its declaration silently won the shared global name. wrapInGridCard()'s
call site therefore ran sidebar's prune (on activeSubagentsByParent)
instead of grid-view's own (on activeSubagents) — the grid's 60s TTL
never fired, so a pill could stay "running" forever if the parent PTY
died before the matching subagent-completed event.

Renamed grid-view's function to pruneStaleGridSubagents and fixed the
stale "called on each grid render cycle" comment while touching this
block (PR #137 review, Finding 1 + Finding 2).

Adds a regression test that loads grid-view.js then sidebar.js in the
real index.html script order and drives wrapInGridCard()'s TTL prune
end to end — pinned red against the shared name, green after the rename.
@JeanBaptisteRenard
JeanBaptisteRenard enabled auto-merge (squash) August 21, 2026 15:00
Renderer files load as plain non-module scripts sharing one global scope,
and index.html loads sidebar.js (:136) after grid-view.js (:132). Both
declared a top-level pruneStaleSubagents(), so the later declaration won:
wrapInGridCard() was calling sidebar.js's prune against
activeSubagentsByParent instead of the grid's own activeSubagents map.

Two consequences: a grid subagent pill whose parent PTY died before the
subagent-completed event stayed "running" forever, and every grid card
re-wrap triggered a spurious prune of the sidebar's map.

Rename the grid-side function; sidebar.js is untouched. The new test pins
both the absence of colliding top-level names between the two files and
the end-to-end TTL prune through the real wrapInGridCard() call site.
@devsuitup
devsuitup force-pushed the fix/grid-subagent-pills branch from 6675576 to 8bd37bc Compare August 23, 2026 20:29
@devsuitup devsuitup changed the title fix(grid): subagent pills were dead — align listener signature with the preload single-arg callback (grid): rename pruneStaleSubagents so sidebar.js stops shadowing it Aug 23, 2026
@devsuitup
devsuitup merged commit 2244c79 into main Aug 23, 2026
7 checks passed
@devsuitup
devsuitup deleted the fix/grid-subagent-pills branch August 23, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants